/*
 * Analyze.cpp
 *
 *  Created on: Oct 4, 2010
 *      Author: gibson
 */

#include "Analyze.h"
#include "DataReader.h"
#include "TH2D.h"
#include "TH1I.h"
#include "TCanvas.h"
#include <iostream>
#include "TPad.h"
#include "TApplication.h"
#include "globals.hh"
#include "TFile.h"
#include "PhotonCounter.h"
#include "TColor.h"

using namespace std;

void TCanvas::Closed()
{
        Emit("Closed()");

        gApplication->Terminate(0);
}

Analyze::Analyze(char* path)
{
	CrystalDistribution(path);
}

Analyze::~Analyze()
{
	;
}

void Analyze::CrystalDistribution(char* path)
{
	dataHisto = new TH2D("dataHisto","dataHisto",72,-0.9,0.9,72,-0.9,0.9);
	dataReader = new DataReader(path);

	char* input = new char[64];
	cout << "Enter kaon number: ";
	cin >> input;
	int kaonNumber = atoi(input);
	cout << "Enter pion number: ";
	cin >> input;
	int pionNumber = atoi(input);

	dataReader->Read(dataHisto,kaonNumber,pionNumber);
	TCanvas* canvas = new TCanvas();
	Double_t r[5] = {1,1,0,0,0};
	Double_t g[5] = {0,1,1,1,0};
	Double_t b[5] = {0,0,0,1,1};
	Double_t stop[5] = {0,.25,.5,.75,1};
	TColor::CreateGradientColorTable(5,stop,r,g,b,20);
	dataHisto->Draw("lego2");

	gApplication->Run(true);

	delete dataReader;
	delete dataHisto;
}
